/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.kmagsoft.jconvert.utils;

import com.kmagsoft.jconvert.gui.ApplicationParams;
import com.kmagsoft.jconvert.gui.BatchConvertGui;
import gr.anagnosg.general.utils.PropertiesUtils;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author anagnosg
 */
public class PropUtils {
 
    
    public static void saveProperty(String propertyName,String propertyValue){
        //Location of property file.
        String propF = ApplicationParams.INSTALLATION_PATH+File.pathSeparatorChar+"db.properties";
        PropertiesUtils.saveProperty(propF, propertyName, propertyValue);
    }
    
    public static List loadParamActionValues(){
        FileReader input = null;
        try {
           input = new FileReader("params.properties"); //pplicationParams.class.getResourceAsStream("../application.properties");// getResourceAsStream("application.properties");
        } catch (FileNotFoundException ex) {
           Logger.getLogger(BatchConvertGui.class.getName()).log(Level.SEVERE, null, ex);
        }
        Properties prop = PropertiesUtils.loadProperties(input,false);

        Enumeration en = prop.keys();
        ArrayList list ;
        HashMap hm = new HashMap();
        while(en.hasMoreElements()){
            String key = (String)en.nextElement();
            String action = key.substring(0,key.lastIndexOf("_"));
            hm.put(action,action);
        }
        list = new ArrayList(hm.values());
        
        return list;
    
    }
    
    
    
    
    
}
